<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>个人信息</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/api.js"></script>
    <script type="text/javascript" src="./script/aui-tab.js" ></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <script type="text/javascript" src="./script/aui-slide.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <!-- <script type="text/javascript" src="./script/jquery-3.2.0.js"></script> -->
    <script type="text/javascript">
        function closeWin() {
            api.closeWin();
        };
    </script>
</head>
<body>
    <!-- 头部 -->
    <header class="aui-bar aui-bar-nav" id="topbar">
        <a class="aui-pull-left aui-btn" onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">个人信息</div>
    </header>
    <div id="list">
        <div class="aui-content aui-margin-b-15 user-info">
            <ul class="aui-list aui-list-in">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner" tapmode onclick="">
                        <div class="aui-list-item-title">头像</div>
                        <div class="aui-list-item-right"><img src=""></div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner" tapmode onclick="">
                        <div class="aui-list-item-title">昵称</div>
                        <div class="aui-list-item-right"><div id="nickname">金可贷</div></div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner" tapmode onclick="">
                        <div class="aui-list-item-title">手机号码</div>
                        <div class="aui-list-item-right"><div id="mobile">13888888888</div></div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner" tapmode onclick="">
                        <div class="aui-list-item-title">真实姓名</div>
                        <div class="aui-list-item-right"><div id="truename">金可贷</div></div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner" tapmode onclick="">
                        <div class="aui-list-item-title">身份证</div>
                        <div class="aui-list-item-right"><div id="IDCard">230803198888888888</div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner" tapmode onclick="">
                        <div class="aui-list-item-title">会员等级</div>
                        <div class="aui-list-item-right"><div>普通会员</div></div>
                    </div>
                </li>
            </ul>
        </div>
        <div class="aui-content aui-margin-b-15 user-info">
            <ul class="aui-list aui-list-in">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner aui-list-item-arrow" tapmode onclick="openHrbBank();">
                        <div class="aui-list-item-title">哈尔滨银行存管账户</div>
                        <div class="aui-list-item-right"><div id="is_hrb">未开通</div></div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <div class="aui-content aui-margin-b-15 user-info">
        <ul class="aui-list aui-list-in">
            <li class="aui-list-item">
                <div class="aui-list-item-inner aui-list-item-arrow" tapmode onclick="change_psw();">
                    <div class="aui-list-item-title">修改登录密码</div>
                    <div class="aui-list-item-right"></div>
                </div>
            </li>
        </ul>
        <ul class="aui-list aui-list-in">
            <li class="aui-list-item">
                <div class="aui-list-item-inner aui-list-item-arrow" tapmode onclick="modifyGestures()">
                    <div class="aui-list-item-title">手势密码</div>
                    <div class="aui-list-item-right"></div>
                </div>
            </li>
        </ul>
    </div>
</body>
<script type="text/template" id="template">
    <div class="aui-content aui-margin-b-15 user-info">
        <ul class="aui-list aui-list-in">
            <li class="aui-list-item">
                <div class="aui-list-item-inner" tapmode onclick="">
                    <div class="aui-list-item-title">头像</div>
                    <div class="aui-list-item-right"><img src=""></div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner" tapmode onclick="">
                    <div class="aui-list-item-title">昵称</div>
                    <div class="aui-list-item-right"><div id="nickname">{{=it.nickname}}</div></div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner" tapmode onclick="">
                    <div class="aui-list-item-title">手机号码</div>
                    <div class="aui-list-item-right"><div id="mobile">{{=it.mobile}}</div></div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner" tapmode onclick="">
                    <div class="aui-list-item-title">真实姓名</div>
                    <div class="aui-list-item-right"><div id="truename">{{=it.username}}</div></div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner" tapmode onclick="">
                    <div class="aui-list-item-title">身份证</div>
                    <div class="aui-list-item-right"><div id="IDCard">{{=it.idno}}</div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner" tapmode onclick="">
                    <div class="aui-list-item-title">会员等级</div>
                    <div class="aui-list-item-right"><div>普通会员</div></div>
                </div>
            </li>
        </ul>
    </div>
    <div class="aui-content aui-margin-b-15 user-info">
        <ul class="aui-list aui-list-in">
            <li class="aui-list-item">
               <div class="aui-list-item-inner" tapmode onclick="openHrbBank();">
                <div class="aui-list-item-title">{{=it.bankname}}</div>
                <div class="aui-list-item-right">
                    <div id="is_hrb">已开通</div>
                </div>
            </div>
        </li>
    </ul>
</div>
</script>
<script type="text/javascript">

    apiready = function(){
        var is_hrb = $api.getStorage('is_hrb');
        if (is_hrb) {
            updateData();
        }else{
            // 未开通银行
        }
        setUserInfo();
    }

    // 更新数据
    function updateData() {
        // 进度提示框
        api.showProgress({
            title: '努力加载中...',
            text: '请稍等...',
            modal: false
        });
        var userid = $api.getStorage('userid');
        // 如果已登录 获取数据
        if (userid) {
            api.ajax({
                url: webAddress + '/index.php?ctl=app_user_center&act=userdetailinfo',
                method: 'post',
                data: {
                    values: {
                        id: userid,
                    },
                }
            }, function(ret, err) {
                if (ret) {
                    // var ret = $api.jsonToStr(ret);
                    // alert(ret);
                    // 关闭下拉刷新控件
                    api.refreshHeaderLoadDone();
                    api.hideProgress();
                    if (ret.status == 0) {
                        alert(ret.info);
                        return false;
                    } else {
                        // // 用户昵称
                        // var user_name = ret.user.user_name;
                        // $api.setStorage('user_name', user_name);
                        // // 用户手机号
                        // var mobile = ret.user.mobile;
                        // userInfo数据
                        var data = ret.user;
                        var nickname = $api.getStorage('user_name');
                        data['nickname'] = nickname;
                        // 调用模板函数
                        templateFun(data);
                    }
                } else {
                    alert(err.msg);
                    // 关闭下拉刷新控件
                    api.refreshHeaderLoadDone();
                    // 关闭加载状态控件
                    api.hideProgress();
                }
            });
        } else {
            // 关闭下拉刷新控件
            api.refreshHeaderLoadDone();
            // 关闭加载状态控件
            api.hideProgress();
            templateFun();
        }
    };

    // 模板赋值函数
    function templateFun(data) {
        var template = $api.byId('template');
        var dotFn = doT.template(template.innerHTML);
        var html = dotFn(data);
        var user = $api.byId('list');
        $api.html(user, html);
    }

    function change_psw(){
        var delay = 0;
        if(api.systemType != 'ios'){
            // delay = 300;
        }
        api.openWin({
            name: 'change-psw',
            url: './change-psw.html',
            bounces:false,
            delay: delay,
            slidBackEnabled:true,
            vScrollBarEnabled:false,
            progress:{
                type:"page"
            }
        });
    };

    // 8月统计
    function my_fund_bill() {
        var delay = 0;
        if (api.systemType != 'ios') {
            // delay = 300;
        }
        api.openWin({
            name: 'my_fund_bill',
            url: './my-fund-bill.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    };

    //修改手势
    function modifyGestures() {

        if (api.systemType == 'ios') {
          api.openWin({
              name: 'ios-unlockSet',
              url: './ios-unlockSet.html',
              bgColor:'#00744b',
              slidBackEnabled:false,
          });
        }else {
        var screenLock = api.require('screenLock');
        screenLock.set({
            color: '#00744b'
        }, function(ret, err) {
            if (ret) {
                alert('添加成功');
            } else {
                alert('添加失败');
            }
        });
        }
    }

    // 自动加载用户资料
    function setUserInfo(){
        var mobileM = $api.getStorage('mobileM');
        var mobileEle = $api.byId('mobile');
        mobileEle.value = mobileM;

        var user_name = $api.getStorage('user_name');
        var nicknameEle = $api.byId('nickname');
        nicknameEle.value = user_name;
    }

    function closeToLogin(){
        $api.setStorage('userid', null);
        var gotoLogin = 'gotoLogin();';
        api.execScript({
            name: 'home',
            frameName: 'user',
            script: gotoLogin,
        });
        api.closeWin();
    }

    // 开通哈尔滨银行
    function openHrbBank(){

    }

</script>

</html>
